﻿<%@ Page Title="" Language="C#" MasterPageFile="~/UI/UserUI/User.Master" AutoEventWireup="true" CodeBehind="SupplierEntry.aspx.cs" Inherits="BoutiquePOS.UI.UserUI.SupplierEntry" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../../Styles/UserUI/Button.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/UserUI/GridView.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/UserUI/DivStyle.css" rel="stylesheet" type="text/css" />
    
    <script language="javascript" type="text/javascript">
        function check() {
            if (document.getElementById('<% = supplierIdTextbox.ClientID %>').value == "") {
                alert("Enter a cabin no.");
            }
            var agree = confirm("Are you sure you want to delete this Supplier Information?");
            if (agree)
                return true;
            else
                return false;
        }

        function validation() {
            if (document.getElementById('<% =supplierNameTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier name cannot be blank ";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% =supplierNameTextBox.ClientID %>').focus();
                return false;
            }
            if (document.getElementById('<% =supplierAddressTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier address can not be blank";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% =supplierAddressTextBox.ClientID %>').focus();
                return false;
            }
            if (document.getElementById('<% =supplierPersonTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier person can not be blank";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% = supplierPersonTextBox.ClientID %>').focus();
                return false;
            }

            if (document.getElementById('<% =supplierCellTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier phone can not be blank";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% = supplierCellTextBox.ClientID %>').focus();
                return false;
            }
            if (document.getElementById('<% =supplierFaxTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier fax can not be blank";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% = supplierFaxTextBox.ClientID %>').focus();
                return false;
            }
            if (document.getElementById('<% =supplierEmailTextBox.ClientID %>').value == "") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Supplier email can not be blank";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                document.getElementById('<% = supplierEmailTextBox.ClientID %>').focus();
                return false;
            }
            if (document.getElementById('<% =supplierTypeSelect.ClientID %>').value == "--Supplier Type Select--") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Select a Supplier Type";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                return false;
            }
            if (document.getElementById('<% =supplierModeSelect.ClientID %>').value == "--Payment Mode Select--") {
                document.getElementById('<%=messageResult.ClientID %>').textContent = "Select a Supplier Mode";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
                return false;
            }

            var digit = "0123456789";
            var templ;
            var len = document.getElementById("<%=supplierCellTextBox.ClientID %>").value.length;
            if (len == 11) {
                for (var i = 0; i < len; i++) {
                    templ = document.getElementById("<%=supplierCellTextBox.ClientID%>").value.substring(i, i + 1);
                    if (digit.indexOf(templ) == -1) {
                        document.getElementById("<%=messageResult.ClientID%>").textContent = "Please Provide Correct contact number";
                        document.getElementById("<%=messageResult.ClientID%>").style.color = "red";
                        document.getElementById("<%=messageResult.ClientID%>").focus();
                        return false;
                    }
                }

            }
            else {
                document.getElementById("<%=messageResult.ClientID%>").textContent = "Contact number should be eleven digit";
                document.getElementById("<%=messageResult.ClientID%>").style.color = "red";
                return false;
            }

            return true;
        }

        function checkEmail() {
            var email = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
            var emailValue = document.getElementById('<%=supplierEmailTextBox.ClientID%>').value;
            var checkresult = emailValue.match(email);
            if (checkresult != null) {
                document.getElementById('<%=messageResult.ClientID%>').textContent = "Emial Address is Valid";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "green";
            }
            else {
                document.getElementById('<%=messageResult.ClientID%>').textContent = "Invalid emial address!";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
            }
        }
        function CheckString() {
            var result = document.getElementById('<%=supplierNameTextBox.ClientID%>').value;
            if (typeof result == 'Letters') {
                //alert('Supplier name should be character');
                document.getElementById('<%=messageResult.ClientID%>').textContent = "";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "green";
            } else {
                document.getElementById('<%=messageResult.ClientID%>').textContent = "Supplier name should be character ";
                document.getElementById('<%=messageResult.ClientID%>').style.color = "red";
            }
        }

    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <fieldset>
        <legend style="color: blue">|| Supplier Info Entry ||</legend>
    
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Id</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierIdTextbox" runat="server" /></div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Name</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierNameTextBox" runat="server" onkeyup="CheckString()"/></div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Address</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierAddressTextBox" runat="server" /></div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Person</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierPersonTextBox" runat="server" /></div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Cell</label></div>
        </div>
        <div class="divColumn">
            <div><input type="text" id="supplierCellTextBox" runat="server" /></div>
        </div>
        
        <%--<div class="divColumn">
           <div><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Enter valid Phone number" ControlToValidate="supplierCellTextBox" ValidationExpression= "^[0-9]{11}$"></asp:RegularExpressionValidator></div> 
        </div>--%>
    </div>
    <br />

    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Fax</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierFaxTextBox" runat="server" /></div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Email</label></div>
        </div>
        <div class="divColumn">
            <div>
                <input type="text" id="supplierEmailTextBox" runat="server" onkeyup="checkEmail()"/></div>
        </div>
    </div>
    <br />

    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Type</label></div>
        </div>
        <div class="divColumn">
            <div>
                <select id="supplierTypeSelect" runat="server">
                    <option>--Supplier Type Select--</option>
                    <option value="1">Company</option>
                    <option value="2">Distributor</option>    
                </select>   
        </div>
    </div>
    </div>
    <br />

    <div class="divRow">
        <div class="divColumn">
            <div>
                <label>
                    Supplier Mode</label></div>
        </div>
        <div class="divColumn">
            <div>
                <select id="supplierModeSelect" runat="server">
                    <option>--Payment Mode Select--</option>
                    <option value="1">Cash</option>
                    <option value="2">Credit</option>
                </select>
            </div>
        </div>
    </div>
    <br />
    <div class="divRow">
        <div class="divColumn">
            <div>
                <p id="messageResult" runat="server">
                </p>
            </div>
        </div>
    </div>
    <div class="divRow">
        <div class="divColumn">
            <div>
                <input type="submit" value="Save" id="saveButton" runat="server" onserverclick="SaveSupplier"
                    class="myButton" onclick="javascript:return validation()"/>&nbsp;
                <input type="submit" value="Clear" id="clearButton" runat="server" onserverclick="ClearButton"
                    class="myButton" />&nbsp;
                <input type="submit" value="Close" id="closeButton" runat="server" onserverclick="CloseButton"
                    class="myButton" />&nbsp;
                <input type="submit" value="Delete" id="deleteButton" runat="server" onserverclick="DeleteButton"
                    class="myButton" onclick="javascript:return check()"/>
            </div>
        </div>
    </div>
    </fieldset>
    
    <fieldset>
        <legend>|| Show Supplier Info ||</legend>
        <div>
            <input id="searchIdTextBox" type="text" runat="server" />
            <input id="searchByIdButton" type="submit" value="Search By ID" class="myButton"
                runat="server" onserverclick="searchByIdButton_Click" />
            <input id="searchNameTextBox" type="text" runat="server" />
            <input id="searchByNameButton" type="submit" value="Search By Name" class="myButton"
                runat="server" onserverclick="searchByNameButton_Click" />
        </div>
        <div>
            <asp:GridView ID="supplierGridView" runat="server" CellPadding="3" AllowPaging="True"
                AutoGenerateColumns="False" Height="100px" BackColor="White" BorderColor="#CCCCCC"
                BorderStyle="None" BorderWidth="1px" CssClass="GridviewStyle" 
                onpageindexchanging="supplierGridView_PageIndexChanging" PageSize="7">
                
                <FooterStyle CssClass="GridViewFooterStyle" />
                <RowStyle ForeColor="#000066" />
                <PagerStyle CssClass="GridViewFooterStyle" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                <HeaderStyle CssClass="GridViewHeaderStyle" Font-Bold="True" />
                <Columns>
                    <asp:BoundField DataField="SupplierId" HeaderText="Supplier Id" />
                    <asp:BoundField DataField="SupplierName" HeaderText="Supplier Name" />
                    <asp:BoundField DataField="SupplierPerson" HeaderText="Supplier Person" />
                    <asp:BoundField DataField="SupplierCell" HeaderText="Supplier Cell" />
                    <asp:CommandField ShowSelectButton="True" />
                </Columns>
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#007DBB" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#00547E" />
            </asp:GridView>
        </div>
    </fieldset>
</asp:Content>

<%--<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
--%>